package com.liangzhong.modules.user.command
{
	import com.common.utils.Debug;
	import com.liangzhong.constants.ApplicationConstants;
	import com.liangzhong.constants.HttpRequestConst;
	import com.liangzhong.constants.NotificationConstants;
	import com.liangzhong.lazy.GetBagInfoCmd;
	import com.liangzhong.lazy.GetGoldPalaceInfoCmd;
	import com.liangzhong.lazy.GetLeagueInfoCmd;
	import com.liangzhong.lazy.GetMailListCmd;
	import com.liangzhong.lazy.GetMatchAwardInfoCmd;
	import com.liangzhong.lazy.GetSignInfoCmd;
	import com.liangzhong.model.AppData;
	import com.liangzhong.proxy.club.ClubProxy;
	import com.liangzhong.proxy.user.UserProxy;
	import com.lz.football.module.framework.AsyncCommand;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;

	/**
	 *用户模块 controller 
	 * @author lxh
	 * 
	 */	
	public class UserCommand extends SimpleCommand
	{
		public function UserCommand()
		{
			super();
		}
		override public function execute(notification:INotification):void
		{
			var userProxy :UserProxy = facade.retrieveProxy(UserProxy.ProxyName) as UserProxy;
			var userId :int = AppData.getInstance().user.uid;
			var userKey :String = AppData.getInstance().user.key;
			switch(notification.getName())
			{
				case ApplicationConstants.User_getUserInfo://获取用户相信信息请求
				{
					//userProxy.requestUserDetailInfo(userId,userKey,HttpRequestConst.User_getUserInfo,HttpRequestConst.Reust_Format_Json);
					break;
				}
				case UserProxy.GetUserInfo_Result://获取用户信息返回
				{
					Debug.echo("User --> get userinfo res",Debug.TRACER);
					//guide data init 2012-11-16
					//判断是否有引导
					if(AppData.getInstance().user.userDetailInfo.guideList 
						&& AppData.getInstance().user.userDetailInfo.guideList.length > 0)
					{
						var taskObj :* = AppData.getInstance().user.userDetailInfo.guideList[0];
						var curGuideId :int = int(taskObj.tid);
						//旧引导
						/*this.sendNotification(ApplicationConstants.GUIDE_GETPLAYERATTR);
						AppData.getInstance().guideManager;
						facade.registerMediator(new GuideMediator(GuideMediator.MediatorName));*/
						//新引导
						if(curGuideId == 0)
						{
						}
						else
						{
							this.sendNotification(NotificationConstants.GUIDE_SET_FINISH);
							//功能引导
						}
						//消息通知
						this.sendNotification(NotificationConstants.GUIDE_START);//引导开始
					}
					else
					{
						this.sendNotification(NotificationConstants.GUIDE_FINISH);//引导结束
						//测试
						//this.sendNotification(NotificationConstants.GUIDE_START);//引导开始
						//this.sendNotification(NotificationConstants.GUIDE_SET_FINISH);
						//facade.registerMediator(new GuideFuncMediator(GuideFuncMediator.MediatorName));
					}
					break;
				}
				case ApplicationConstants.Main_Get_User_Base_Info://获取用户相关信息
				{
					//获取俱乐部信息
					this.sendNotification(ApplicationConstants.Club_Get_ClubInfo);
					//获取背包信息
					//获取邮件信息
					//获取联赛信息
					//获取签到信息
					//获取12宫信息
					var delayTime :Number = .2;
					var asyncCmd :AsyncCommand = new AsyncCommand(delayTime,
						new GetBagInfoCmd(delayTime),
						new GetMailListCmd(delayTime),
						new GetLeagueInfoCmd(delayTime),
						new GetMatchAwardInfoCmd(delayTime),
						new GetSignInfoCmd(),
						new GetGoldPalaceInfoCmd(delayTime));
					asyncCmd.start();
					break;
				}
			}
		}
	}
}